/* lfsControl.c - lfsControl */

#include <xinu.h>

/*------------------------------------------------------------------------
 * lfsControl - Provide control functions for a local 
 * 				file system master device
 *------------------------------------------------------------------------
 */
devcall	lfsControl (
	 struct dentry	*devptr,	/* entry in device switch table	*/
	 int32	func,				/* a control function		*/
	 int32	arg1,				/* argument #1			*/
	 int32	arg2				/* argument #2			*/
	)
{
	int32	retval;				/* return value from func. call	*/

	switch (func) {
	
	case LFS_CTL_FORMAT:
		wait(Lf_data.lf_mutex);
		retval = lfscreate(LF_DISK_DEV, arg1, arg2);
		signal(Lf_data.lf_mutex);
		return retval;
	
	case LFS_CTL_MKDIR:
		//wait(Lf_data.lf_mutex);
		retval = lfsmkdir(devptr, (char *)arg1);
		//signal(Lf_data.lf_mutex);
		return retval;
	
	case LFS_CTL_RMDIR:
		wait(Lf_data.lf_mutex);
		retval = lfsrmdir(devptr, (char *)arg1);
		signal(Lf_data.lf_mutex);
		return retval;
	
	case LFS_CTL_DEL:
		wait(Lf_data.lf_mutex);
		retval = lfsdel(devptr, (char *)arg1);
		signal(Lf_data.lf_mutex);
		return retval;

	default:
		kprintf("lfControl: function %d not valid\n\r", func);
		return SYSERR;
	}
}



